import { createSlice } from "@reduxjs/toolkit";
import {request} from "../../utils/requset";


const pzStore = createSlice({
  name: 'pz',
  initialState: {
    sysConfig: {}
  },
  reducers: {
    setSysConfig(state, action) {
      state.sysConfig = action.payload;
    }
  }
})

const { setSysConfig } = pzStore.actions;

const loadSysConfig = () => {
    return async (dispatch) => {
        const res = await request.post("/sys/get_sys_config", {
            config:"basic_config"
        })
        const data = await res.data
        dispatch(setSysConfig(data))
    }
}

export { setSysConfig, loadSysConfig }

const pzReducer = pzStore.reducer

export default pzReducer